/*
 * @Author: Aaron
 * @Date: 2021-08-25 17:42:10
 * @LastEditors: Aaron
 * @LastEditTime: 2022-03-17 15:18:14
 * @Description: file content
 * @FilePath: \ias_ui\src\api\reason\dataO2o.js
 * @Company: 沃尔玛
 */
import request from '@/utils/reason/requestO2o'

export function initData(url, params) {
  return request({
    url: url,
    method: 'post',
    data: params
  })
}

export function insertInfo(val) {
  return request({
    url: '/reasonController/add',
    method: 'post',
    data: val
  })
}

export function updateInfo(val) {
  return request({
    url: '/reasonController/update',
    method: 'post',
    data: val
  })
}

export function deleteInfo(url, params) {
  return request({
    url: url,
    method: 'get',
    params
  })
}

export function approvalAdd(url, val, approvalFlagTwo) {
  return request({
    url: url,
    method: 'post',
    data: { ids: val, approvalFlagTwo: approvalFlagTwo }
  })
}

export function approvalUpdate(url, val, approvalFlagTwo) {
  return request({
    url: url,
    method: 'post',
    data: { ids: val, approvalFlagTwo: approvalFlagTwo }
  })
}

export function approvalAddBuyer(url, val) {
  return request({
    url: url,
    method: 'post',
    data: val
  })
}

export function approvalTask(url, val, approvalFlagOne) {
  return request({
    url: '/approvalConditionController/approvalTask',
    method: 'post',
    data: { finelineName: '页面调用' }
  })
}

export function selectApproval(url, val) {
  return request({
    url: url,
    method: 'post',
    data: { ids: val }
  })
}

/**
 * 验证输入长度
 * @param {*} rule
 * @param {*} value
 * @param {*} callback
 */
export function checkLong(rule, value, callback) {
  if (value) {
    if (value.length < rule.length && value.length >= 0) {
      callback()
    } else {
      callback(new Error('输入不可超过' + rule.length + '个字符'))
    }
  } else {
    callback()
  }
}
